import 'package:dio/dio.dart';

import 'HttpManager.dart';
import 'UrlPath.dart';

///
/// 对应项目中业务开发时候的调用接口
///
class Api {
  /// 示例请求
  static loginOther(Map<String, dynamic> param) {
    return HttpManager.getInstance().get(UrlPath.baseUrl, params: param);
  }

  /// App检测升级
  static updateApp(String baseUrl, Map<String, dynamic> param) {
    return HttpManager.getInstance(baseUrl: baseUrl).get(UrlPath.firImAppId, params: param);
  }

  //=================================== 共用 ========================================
  /// app配置列表[单对象]
  static postAppSetInfo(Map<String, dynamic> param) {
    return HttpManager.getInstance().post(UrlPath.appSetInfo, params: param);
  }

  /// 单文件上传接口
  static uploadFile(MultipartFile multipartFile, {ProgressCallback? onSendProgress}) {
    return HttpManager.getInstance().uploadFile(UrlPath.uploadFile, multipartFile: multipartFile, onSendProgress: onSendProgress);
  }

  /// 多文件上传接口
  static uploadFiles(List<MultipartFile> multipartFiles, {ProgressCallback? onSendProgress}) {
    return HttpManager.getInstance().uploadFiles(UrlPath.uploadFiles, multipartFiles: multipartFiles, onSendProgress: onSendProgress);
  }

  /// 文件下载
  /// urlPath   下载路径
  /// fileName  文件名称
  static downLoad(String urlPath, String fileName) {
    return HttpManager.getInstance(baseUrl: "").downLoad(urlPath, fileName);
  }

  //=================================== 调查任务 ========================================
  /// 获取任务统计 首页
  static getUserTaskCount() {
    return HttpManager.getInstance().post(UrlPath.getUserTaskCount);
  }

  /// 获取任务列表
  static listUserTask(Map<String, dynamic> param) {
    return HttpManager.getInstance().post(UrlPath.listUserTask, params: param, withLoading: false);
  }

  /// 获取用户任务详情
  static getUserTaskDetail(Map<String, dynamic> param) {
    return HttpManager.getInstance().post(UrlPath.getUserTaskDetail, params: param);
  }

  /// 获取异常样本列表
  static listTaskWrite(Map<String, dynamic> param) {
    return HttpManager.getInstance().post(UrlPath.listTaskWrite, params: param);
  }

  /// 删除异常样本
  static delTaskWrite(Map<String, dynamic> param) {
    return HttpManager.getInstance().post(UrlPath.delTaskWrite, params: param);
  }

  /// 保存任务文件信息
  static saveTaskFile(Map<String, dynamic> param) {
    return HttpManager.getInstance().post(UrlPath.saveTaskFile, params: param);
  }
  /// 完成调研
  static completeWrite(Map<String, dynamic> param) {
    return HttpManager.getInstance().post(UrlPath.completeWrite, params: param);
  }



















  //=================================== 登录 ========================================
  /// 登录
  static login(Map<String, dynamic> param) {
    return HttpManager.getInstance().post(UrlPath.login, params: param);
  }

  /// 获取短信验证码
  static sendSignCodeByAliyun(Map<String, dynamic> param) {
    return HttpManager.getInstance().post(UrlPath.sendSignCodeByAliyun, params: param);
  }

  /// 修改密码接口
  static updateLoginPassword(Map<String, dynamic> param) {
    return HttpManager.getInstance().post(UrlPath.updateLoginPassword, params: param);
  }

  /// 更新用户头像
  static updateUserAvatar(Map<String, dynamic> param) {
    return HttpManager.getInstance().post(UrlPath.updateUserAvatar, params: param);
  }
}
